const path = require('path');

module.exports = {
  outputDir: './build',

  devServer: {
    proxy: {
      '/api': {
        target: 'http://152.136.185.210:4000',
        changeOrigin: true, // 如果接口跨域，需要进行这个参数配置
        // secure: true, //接受对方是https的接口
        pathRewrite: {
          '^/api': '/',
        },
      },
    },

    // historyApiFullback: true,
  },

  publicPath: '/cms',

  // 该对象会被 webpack-merge 合并入最终的 webpack 配置。(和webpack属性完全一致)

  // 对象形式
  /* configureWebpack: {
                resolve: {
                    alias: {
                        components: '@/components',
                    },
                },
            }, */

  // 函数形式
  configureWebpack: (config) => {
    config.resolve.extensions = ['.ts', '.js', '.vue', 'json', '.jsx', '.tsx'];
    config.resolve.alias = {
      '@': path.resolve(__dirname, 'src'),
      components: '@/components',
    };
  },

  // 链式函数形式
  // chainWebpack: (config) => {
  //   config.resolve.alias
  //     .set('@', path.resolve(__dirname, 'src'))
  //     .set('components', '@/components');
  // },

  pages: {
    index: {
      entry: 'src/main.ts',
      template: 'public/index.html',
      filename: 'index.html',
      title: '某不知名后台管理',
    },
  },
};
